package com.jcoinexchange.web.exception;

import com.jcoinexchange.web.entity.ResponseCode;
import com.jcoinexchange.web.util.StringFormatUtil;

/**
 * @desc 系统内部异常
 *
 * @author tony
 * @createDate 2024/4/8 10:50 上午
 */
public class InternalException extends RuntimeException{
    private int code;
    private String errorMsg;

    private InternalException(){}

    public InternalException(ResponseCode errorCode) {
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
        this.errorMsg = errorCode.getMsg();
    }

    public InternalException(ResponseCode errorCode, String format, Object... args) {
        super(StringFormatUtil.format(format, args));
        this.code = errorCode.getCode();
        this.errorMsg = StringFormatUtil.format(format, args);
    }

    public int getCode() {
        return code;
    }

    public String getErrorMsg() {
        return errorMsg;
    }
}
